#include <my_header.h>

#define TIMES 10000000
int global =0;

void * threadFunc(void * arg)
{

    printf("I am child thread\n");

    for(int i = 0;i<TIMES;i++)
    {
        global++;
    }
    printf("child thread stop \n");
    return NULL;
}

/*验证线程共享堆空间 */
int main(int argc, char *argv[])
{
    ARGS_CHECK(argc,1);

    pthread_t tid;
    int ret = pthread_create(&tid,NULL,threadFunc,NULL);
    ERROR_CHECK(ret,-1,"pthread_create");
    printf("I am main thread\n");

    for(int i = 0;i<TIMES;i++)
    {
        global++;
    }
    printf("main thread stop\n");

    pthread_join(tid,NULL);

    printf("all over,global = %d \n",global);

    return 0;
}

